home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_iconbox_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  3KB  |  96 lines

  1. #include "ewl_test.h"
  2.  
  3. Ewl_Widget* ib;
  4. static Ewl_Widget* ewl_iconbox_button = NULL;
  5.  
  6. void icon_click_cb(Ewl_Widget *w __UNUSED__, void *ev_data, void *user_data __UNUSED__) {
  7.     Ewl_Event_Mouse_Down *ev = ev_data;
  8.     if (ev->clicks > 1)
  9.         printf("Icon clicked!\n");
  10. }
  11.  
  12. void add_icons_cb(Ewl_Widget *w __UNUSED__, void *ev_data __UNUSED__, void *user_data __UNUSED__) {
  13.         Ewl_Iconbox_Icon* icon = ewl_iconbox_icon_add(EWL_ICONBOX(ib), "Draw", PACKAGE_DATA_DIR "/images/Draw.png");
  14.         printf("Loading %s\n", PACKAGE_DATA_DIR "/images/Draw.png");
  15.         ewl_callback_prepend(EWL_WIDGET(icon), EWL_CALLBACK_CLICKED, icon_click_cb, NULL);
  16.         
  17.         ewl_iconbox_icon_arrange(EWL_ICONBOX(ib));
  18.  
  19.         ewl_iconbox_icon_add(EWL_ICONBOX(ib),"End", PACKAGE_DATA_DIR "/images/End.png");
  20.         ewl_iconbox_icon_add(EWL_ICONBOX(ib),"Card", PACKAGE_DATA_DIR "/images/NewBCard.png");
  21.         ewl_iconbox_icon_add(EWL_ICONBOX(ib),"Open", PACKAGE_DATA_DIR "/images/Open.png");
  22.         ewl_iconbox_icon_add(EWL_ICONBOX(ib),"Package", PACKAGE_DATA_DIR "/images/Package.png");
  23.         ewl_iconbox_icon_add(EWL_ICONBOX(ib),"World", PACKAGE_DATA_DIR "/images/World.png");
  24.         
  25. }
  26.  
  27. void
  28.  __destroy_iconbox_test_window(Ewl_Widget *main_win, void *ev_data __UNUSED__, void *user_data __UNUSED__)
  29.  {
  30.         ewl_widget_destroy(main_win);
  31.     ewl_callback_append(ewl_iconbox_button, EWL_CALLBACK_CLICKED,
  32.                                       __create_iconbox_test_window, NULL);
  33.  
  34.  
  35.         return;
  36.  }
  37.  
  38. void
  39. __create_iconbox_test_window(Ewl_Widget * w __UNUSED__, void *ev_data __UNUSED__,
  40.                                           void *user_data __UNUSED__)
  41. {
  42.         Ewl_Widget* ib_win;
  43.         Ewl_Widget* box;
  44.         Ewl_Widget* button;
  45.  
  46.         ewl_iconbox_button=w;
  47.         
  48.         ib_win= ewl_window_new();
  49.  
  50.                 if (w) {
  51.                         ewl_callback_del(w, EWL_CALLBACK_CLICKED,
  52.                                         __create_iconbox_test_window);
  53.                         ewl_callback_append(ib_win, EWL_CALLBACK_DELETE_WINDOW,
  54.                                     __destroy_iconbox_test_window, NULL);
  55.                 } else
  56.                         ewl_callback_append(ib_win, EWL_CALLBACK_DELETE_WINDOW,
  57.                                         __close_main_window, NULL);
  58.  
  59.         
  60.         ewl_window_title_set(EWL_WINDOW(ib_win), "Icon Box");
  61.         ewl_window_name_set(EWL_WINDOW(ib_win), "Icon Box");
  62.         ewl_window_class_set(EWL_WINDOW(ib_win), "Icon Box");
  63.         ewl_object_size_request(EWL_OBJECT(ib_win), 500,500);
  64.  
  65.         
  66.         ib = ewl_iconbox_new();
  67.         //ewl_object_fill_policy_set(EWL_OBJECT(ib), EWL_FLAG_FILL_SHRINK);
  68.         ewl_iconbox_editable_set(EWL_ICONBOX(ib), 1);
  69.  
  70.  
  71.         box = ewl_hbox_new();
  72.         button = ewl_button_new();
  73.         ewl_button_label_set(EWL_BUTTON(button), "Add Icons");
  74.         ewl_widget_show(button);
  75.  
  76.         
  77.         ewl_container_child_append(EWL_CONTAINER(ib_win), box);
  78.         ewl_object_fill_policy_set(EWL_OBJECT(ib_win), EWL_FLAG_FILL_ALL);
  79.         ewl_object_fill_policy_set(EWL_OBJECT(box), EWL_FLAG_FILL_ALL);
  80.         ewl_container_child_append(EWL_CONTAINER(box), button);
  81.         ewl_object_maximum_size_set(EWL_OBJECT(button), 50, 50);
  82.         
  83.         ewl_container_child_append(EWL_CONTAINER(box), ib);
  84.         ewl_widget_show(box);
  85.         
  86.  
  87.  
  88.         ewl_widget_show(ib_win);
  89.         ewl_widget_show(ib);
  90.  
  91.  
  92.          ewl_callback_append(button, EWL_CALLBACK_MOUSE_DOWN,
  93.                  add_icons_cb, NULL);
  94.  
  95. }
  96.